#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>

#include <matrix4x4.h>
#include <assert.h>

matrix4x4_t *
matrix4x4_new( void )
{
  return calloc( 1, sizeof(matrix4x4_t) );
}

void
matrix4x4_free( matrix4x4_t *m )
{
  assert( m != NULL );
  free( m );
}

char *
matrix4x4_str( const matrix4x4_t m )
{
  char *s = NULL;

  asprintf( &s,
	    "[ [ % 3.3lf, % 3.3lf, % 3.3lf, % 3.3lf ],\n"
	    "  [ % 3.3lf, % 3.3lf, % 3.3lf, % 3.3lf ],\n"
	    "  [ % 3.3lf, % 3.3lf, % 3.3lf, % 3.3lf ],\n"
	    "  [ % 3.3lf, % 3.3lf, % 3.3lf, % 3.3lf ] ]",
	    m.data[ 0 ][ 0 ], m.data[ 0 ][ 1 ],
	    m.data[ 0 ][ 2 ], m.data[ 0 ][ 3 ],
	    m.data[ 1 ][ 0 ], m.data[ 1 ][ 1 ],
	    m.data[ 1 ][ 2 ], m.data[ 1 ][ 3 ],
	    m.data[ 2 ][ 0 ], m.data[ 2 ][ 1 ],
	    m.data[ 2 ][ 2 ], m.data[ 2 ][ 3 ],
	    m.data[ 3 ][ 0 ], m.data[ 3 ][ 1 ],
	    m.data[ 3 ][ 2 ], m.data[ 3 ][ 3 ]
	    );
  return s;
}

